package topo.data;

import com.zhtelecom.common.topograph.TopoNode;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.ImageIcon;

public class NodeType implements Serializable {
    private String nodeType = "";

    private String imageFileName = "";

    private String typeOIDCharacter = "";

    private String typeDescCharacter = "";

    private String typeDesc = "";

    private String typeParam = "";
    public static Map<String, NodeType> nodeTypeMap;
    public static List<NodeType> nodeTypeList;
    private static final String[][] nodeTypeArray = { { "windows服务器", "windows.jpg", "", "", "", "" }, { "服务器", "server_pc.png", "", "", "", "" }, { "计算机", "pc_color.png", "", "", "", "" }, { "交换机", "switch_lan.png", "", "", "", "" }, { "路由交换机", "router1.png", "", "", "", "" }, { "路由器", "Cisco7600Router.jpg", "", "", "", "" }, { "其他设备类型", "AccessPoint.png", "", "", "", "" } };

    static {
        nodeTypeMap = new HashMap();
        nodeTypeList = new ArrayList();
        for (int i = 0; i < nodeTypeArray.length; i++) {
            String[] nodeTypeParams = nodeTypeArray[i];
            NodeType nodeType = new NodeType(nodeTypeParams[0], nodeTypeParams[1], nodeTypeParams[2], nodeTypeParams[3], nodeTypeParams[4], nodeTypeParams[5]);
            nodeTypeMap.put(nodeType.getNodeType(), nodeType);
            nodeTypeList.add(nodeType);
        }
    }

    public NodeType(String nodeType, String imageFileName, String typeOIDCharacter, String typeDescCharacter, String typeDesc, String typeParam) {
        this.nodeType = nodeType;
        this.imageFileName = imageFileName;
        this.typeOIDCharacter = typeOIDCharacter;
        this.typeDescCharacter = typeDescCharacter;
        this.typeDesc = typeDesc;
        this.typeParam = typeParam;
    }

    public static List<NodeType> getNodeTypeList() {
        return nodeTypeList;
    }

    public static NodeType getNodeTypeByKey(String nodeType) {
        return (NodeType) nodeTypeMap.get(nodeType);
    }

    public ImageIcon getTypeImage() {
        ImageIcon icon = null;
        try {
            URL url = getClass().getClassLoader().getResource("topoimage/" + this.imageFileName);
            icon = new ImageIcon(url);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        if (icon == null) {
            icon = TopoNode.defaultIcon;
        }

        return icon;
    }

    public NodeType() {
    }

    public void setNodeType(String nodeType) {
        this.nodeType = nodeType;
    }

    public String getNodeType() {
        return this.nodeType;
    }

    public String getImageFileName() {
        return this.imageFileName;
    }

    public void setImageFileName(String imageFileName) {
        this.imageFileName = imageFileName;
    }

    public String getTypeDesc() {
        return this.typeDesc;
    }

    public String getTypeParam() {
        return this.typeParam;
    }

    public void setTypeDesc(String typeDesc) {
        this.typeDesc = typeDesc;
    }

    public void setTypeParam(String typeParam) {
        this.typeParam = typeParam;
    }

    public boolean equals(Object obj) {
        if ((obj instanceof NodeType)) {
            NodeType theDBkey = (NodeType) obj;
            if (getNodeType().equals(theDBkey.getNodeType())) {
                return true;
            }
        }
        return false;
    }

    public int hashCode() {
        return getNodeType().hashCode();
    }

    public String toString() {
        String name = "设备类型[" + getNodeType() + "]";
        return name;
    }

    public String getTypeOIDCharacter() {
        return this.typeOIDCharacter;
    }

    public void setTypeOIDCharacter(String typeOIDCharacter) {
        this.typeOIDCharacter = typeOIDCharacter;
    }

    public String getTypeDescCharacter() {
        return this.typeDescCharacter;
    }

    public void setTypeDescCharacter(String typeDescCharacter) {
        this.typeDescCharacter = typeDescCharacter;
    }
}